<?php

namespace app\admin\model;

use think\Model;


class BydAgreement extends Model
{

    

    

    // 表名
    protected $name = 'byd_agreement';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'state_text'
    ];
    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getStateList()
    {
        return ['0' => __('b1注册'), '1' => __('d1注册'), '2' => __('已收货'), '3' => __('已安装'), '4' => __('支付前'), '5' => __('是否安装'), '6' => __('楼盘D端协议'), '7' => __('楼盘B端协议'), '8' => __('b2注册'), '9' => __('b3注册'), '10' => __('d2注册'), '11' => __('d3注册'), '12' => __('区域经营权'), '14' => __('积分商品')];
    }


    public function getStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
